<?php
html::printPath(
    array(
        'public.home-header' => '/page',
        'signUp.form-title' => ''
    ),
    'signUp.form-desc'
);
$msg->printMessages();

if ($lostPasswordLogin) {
    echo '<ul class="commandList">';
    echo '<li class="emailCommand">' . html::anchor('/auth/forgottenPasswordForm' . $lostPasswordLogin, text::get('public-forgottenPassword-title')) . '</li>';
    echo '</ul>';
}

$loginSuggestMethod = "suggestLogin(this, '" . url::site('/auth/suggestLogin') . "')";

$fb = new FormBuilder('person', $formData);
$fb->secureConnection();
$fb->setFormId('signUpForm');
$fb->setAction('/signUp/create');
$fb->hidden('is_robot');
$fb->text('first_name')->required()->onChange($loginSuggestMethod);
$fb->text('last_name')->required()->onChange($loginSuggestMethod);
$fb->text('title');
$fb->radioButtons('gender', array('M','F'), 'person.gender-')->required();
$fb->date('birth_date')->required();

$fb->delimiter(text::get('person-idetificationPapers'));
$fb->description(text::get('person-weNeedIdCardNumber'));
$fb->comboBox('idcard_type', $idcardTypeOptions);
$fb->text('idcard_number');
$fb->comboBox('citizenship_code', $countryOptions)->hint()->required();

$fb->delimiter(text::get('person-permanentAddress'));
$fb->text('street')->required();
$fb->text('city')->required();
$fb->text('postal_code')->required();
$fb->comboBox('country_code', $countryOptions)->required();

$fb->delimiter();
$fb->comboBox('country_of_residence_code', $countryOptions)->required();
$fb->comboBox('preferred_language', form::languageOptions())->noEmptyOption()->required();

$fb->spacer();
$fb->text('telephone');
$fb->text('email')->required()->onChange($loginSuggestMethod);
$fb->yesNoBox('is_ztp')->hint();

$fb->delimiter();
$fb->description(text::get('person-organization-info'));
$fb->comboBox('organization_id', $organizationOptions)->hint();

$fb->delimiter();
$fb->text('login')->required();
$fb->password('password')->required()->appendix(text::get('person.password-minLength'));
$fb->spacer();
// $fb->yesNoBox('privateData');
$fb->yesNoBox('personalDataAgreement')->required()->labelKey('signUp.personalDataAgreement')
        ->appendix(html::moreInfoPopup('/signUp/personalDataAgreement', text::get('signUp.personalDataAgreement-link')));
$fb->button('submit', 'button.create');
$fb->write();
?>

<script>
    $(document).ready(function() {
        document.getElementById('is_robot').value = 'no';
        if ($('ul.errorMessages').size() == 0) {
            document.getElementById('login').value = '';
            document.getElementById('password').value = '';
        }
        document.getElementById('personalDataAgreement').value = '';
    });
</script>